home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / TXTWDTH.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  1.0 KB  |  31 lines

  1.  
  2. /*  txtwdth.c  -- textwidth, p.864    */
  3. #include <graphics.h>
  4. char text[] = "Text to be underlined";
  5. main()
  6. {
  7.     int graphdriver = DETECT, graphmode, xmax, ymax, xsize, ysize;
  8.                 /* Detect and initialize graphics system */
  9.     initgraph(&graphdriver, &graphmode, "c:\\turboc");
  10.                 /* Display a graphics window with a text */
  11.     xmax = getmaxx();
  12.     ymax = getmaxy();
  13.        xsize = xmax - 100;
  14.         ysize = ymax - 60;
  15.         setviewport(50, 30, xsize+50, ysize+30,1);
  16.         setfillstyle(SOLID_FILL, RED);
  17.         setcolor(YELLOW);
  18.         bar3d(0,0,xsize,ysize,0,1);
  19.         /* Print text then underline by drawing a line underneath */
  20.     settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 1);
  21.      settextjustify(LEFT_TEXT, BOTTOM_TEXT);
  22.      outtextxy(10, ysize/2, text);
  23.      moveto(10, ysize/2+1);
  24.                     /* Draw the underline */
  25.     linerel(textwidth(text),0);
  26.                     /* Wait until a key is pressed */
  27.     moveto(10,ysize-10);
  28.     outtext("Press any key to exit:");
  29.     getch();
  30.     closegraph();                 /* Exit graphics library */
  31. }